/**
 * “商品管理”相关接口
 */
import request from '@/utils/request'

export default {

  /** addGoods.vue start  **/
  saveGoods(goodInfo, imgInfos, attrInfos){
    const data = goodInfo;
    data.imgInfos = imgInfos;
    data.attrInfos = attrInfos;
    return request({
      url: 'shopGoods/addInfo',
      method: 'post',
      data
    })
  },
  getAttributes(params){
    const data = {
      catId: params
    }
    return request({
      url: 'shopAttribute/data/list',
      method: 'post',
      data
    })
  },
  /** addGoods.vue end **/
  /** reviewGoods.vue start **/
  initCategory(params){
    /** 分页获取商品数据 **/
    const data = {
      catId:params.catId
    }
    return request({
      url: 'shopCategory/checkCategory',
      method: 'post',
      data
    })
  },
  getGoodsDataList(params, status, page, size){
    /** 分页获取商品数据 **/
    const data = {
      shopGoods: params,
      status: status
    }
    return request({
      url: 'shopGoods/listByPage?page='+page+'&size='+size,
      method: 'post',
      data
    })
  },
  getGoodsAllInfoById(params){
    const data = {
      goodsId: ""+params.id,
      catId: ""+params.catId
    };
    return request({
      url: 'shopGoods/allInfoById',
      method: 'post',
      data
    })
  },
  initProducts(params){
    const data = {
      goodsId: params.id,
      catId: params.catId
    };
    return request({
      url: 'shopGoodsAttr/initProductsInfo',
      method: 'post',
      data
    })
  },
  getPhotoList(params){
    const data = {
      goodsId:params.goodsId,
      type:params.type
    }
    return request({
      url: 'shopPhoto/data/list',
      method: 'post',
      data
    })
  },
  getGoodsAttrs(params){
    /** 获取商品的分类属性值 **/
    const data = {
      goodsId: params.goodsId,
      catId: params.catId
    }
    return request({
      url: 'shopGoodsAttr/attrInfoByGoodsId',
      method: 'post',
      data
    })
  },
  deleteGoodsById(params){
    /** 删除商品数据通过ID **/
    const data = {
      id: params
    }
    return request({
      url: 'shopGoods/deleteById',
      method: 'post',
      data
    })
  },
  updateGoods(params){
    /** 更新商品数据通过ID-主要是改变状态 **/
    const data = params;
    return request({
      url:'shopGoods/data/updateById',
      method:'post',
      data
    })
  },
  updateGoodsAllInfo(goodInfo, imgInfos, attrInfos){
    const data ={
      goodInfo: goodInfo,
      imgInfos: imgInfos,
      attrInfos: attrInfos
    }
    return request({
      url:'shopGoods/updateAllInfo',
      method:'post',
      data
    })
  },
  saveProductsInfos(params){
    /** 保存库存信息，更新商品状态 **/
    const data = params;
    return request({
      url:'shopProducts/saveInfos',
      method:'post',
      data
    })
  },
  shopGoodsInfo(params){
    /** 查询商品单条数据 **/
    const data = params;
    return request({
      url:'shopGoods/data/info',
      method:'post',
      data
    })
  },
  /** reviewGoods.vue end **/
  checkgoodsSn(params){
    const data = {
      goodsSn: params
    }
    return request({
      url: 'shopGoods/data/list',
      method: 'post',
      data
    })
  }
}
